package com.hacpai.android.md.model.api;

import com.hacpai.android.md.model.entity.Article;
import com.hacpai.android.md.model.entity.ArticleWithComment;
import com.hacpai.android.md.model.entity.Notification;
import com.hacpai.android.md.model.entity.Result;
import com.hacpai.android.md.model.entity.TabType;

import java.util.List;

import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;

public interface ApiService {



    //=====
    // 领域
    //=====
    @GET("domains")
    Call<Result.Data<Result.DomainData>> getDomainList();


    //=====
    // 话题
    //=====

    @GET("articles/{latest}")
    Call<Result.Data<Result.ArticleData>> getLatestArticlesList(
            @Path("latest") String path,
            @Query("p") Integer page
    );

    @GET("articles/latest/{hot}")
    Call<Result.Data<Result.ArticleData>> getLatestHotArticlesList(
            @Path("hot") String path,
            @Query("p") Integer page
    );

    @GET("articles/latest/{good}")
    Call<Result.Data<Result.ArticleData>> getLatestGoodArticlesList(
            @Path("good") String path,
            @Query("p") Integer page
    );

    @GET("articles/latest/{reply}")
    Call<Result.Data<Result.ArticleData>> getLatestReplyArticlesList(
            @Path("reply") String path,
            @Query("p") Integer page
    );




//    @GET("topics")
//    Call<Result.Data<Result.ArticleData>> getTopicList(
//            @Query("tab") TabType tab,
//            @Query("page") Integer page,
//            @Query("limit") Integer limit,
//            @Query("mdrender") Boolean mdrender
//    );

    @GET("article/{articleId}")
    Call<Result.Data<ArticleWithComment>> getTopic(
            @Path("articleId") String topicId,
            @Query("page") int pageCount
    );

    @POST("topics")
    @FormUrlEncoded
    Call<Result.CreateTopic> createTopic(
            @Field("accesstoken") String accessToken,
            @Field("tab") TabType tab,
            @Field("title") String title,
            @Field("content") String content
    );

    //=========
    // 话题收藏
    //=========

    @POST("topic_collect/collect")
    @FormUrlEncoded
    Call<Result> collectTopic(
            @Field("accesstoken") String accessToken,
            @Field("topic_id") String topicId
    );

    @POST("topic_collect/de_collect")
    @FormUrlEncoded
    Call<Result> decollectTopic(
            @Field("accesstoken") String accessToken,
            @Field("topic_id") String topicId
    );
    //=========
    // hac 最近回复
    //=========
    @GET("user/{userName}/comments")
    Call<Result.Data<Result.ArticleData>> getCommentTopicList(
            @Path("userName") String userName ,
            @Query("p") int page
    );

    //=========
    // hac 最近发布
    //=========
    @GET("user/{userName}/articles")
    Call<Result.Data<Result.ArticleData>> getPostTopicList(
            @Path("userName") String userName ,
            @Query("p") int page
    );

    //=========
    // hac 关注帖子
    //=========
    @GET("user/{userName}/watching/articles")
    Call<Result.Data<Result.ArticleData>> getWatchTopicList(
            @Path("userName") String userName ,
            @Query("p") int page
    );


    //=====
    // 回复
    //=====

    @POST("topic/{topicId}/replies")
    @FormUrlEncoded
    Call<Result.ReplyTopic> createReply(
            @Path("topicId") String topicId,
            @Field("accesstoken") String accessToken,
            @Field("content") String content,
            @Field("reply_id") String targetId
    );


    //=====
    // 用户
    //=====

    @GET("user/{userName}")
    Call<Result.Data<Result.UserDate>> getUser(
            @Path("userName") String loginName
    );

    @POST("accesstoken")
    @FormUrlEncoded
    Call<Result.Login> accessToken(
            @Field("accesstoken") String accessToken
    );


//hac login
    @POST("login")
    Call<Result.LoginDate> login(
            @Body ApiDefine.LoginUser loginUser
            );

//hac logout
    @POST("logout")
    Call<Result> logout(
    );

    @POST("article")
    Call<Result> article(
            @Body ApiDefine.PostArticle article
    );


    //=========
    // 消息通知
    //=========

    @GET("message/count")
    Call<Result.Data<Integer>> getMessageCount(
            @Query("accesstoken") String accessToken
    );

    @GET("messages")
    Call<Result.Data<Notification>> getMessages(
            @Query("accesstoken") String accessToken,
            @Query("mdrender") Boolean mdrender
    );

    @POST("message/mark_all")
    @FormUrlEncoded
    Call<Result> markAllMessageRead(
            @Field("accesstoken") String accessToken
    );

}
